<template>
  <div class="scope-box">
    <h3>作用域插槽</h3>
    <h3>{{ count }}</h3>
    <div class="content">
      <!-- 把films绑定给了插槽 -->
      <slot name="one" :films="films"></slot>
      <slot name="two" :names="names"></slot>
      <button @click="change">改变</button>
    </div>
  </div>
</template>

<script>
export default {
  props: ['count'],
  data () {
    return {
      films: [
        {
          name: '金刚川'
        },
        {
          name: '战狼1和2'
        },
        {
          name: '红海行动'
        }
      ],
      names: [
        {
          name: '顿健康'
        },
        {
          name: '刘佩佩'
        },
        {
          name: '张非凡'
        },
        {
          name: '范晓瑞'
        },
        {
          name: '王守龙'
        }
      ]
    }
  },
  methods: {
    change () {
      this.films[0].name = '大金刚'
    }
  }
}
</script>

<style>
.scope-box {
  padding: 10px;
  background-color: yellowgreen;
}
.content {
  border: 1px solid #000;
  padding: 15px;
  background-color: skyblue;
}
</style>
